#ifndef _TEXT_DB_H_
#define _TEXT_DB_H_

#include <fstream>
#include <map>
#include <list>

#include "Category.h"
#include "Product.h"

class TextDB
{
  private:
	 const char* filename;
	 std::fstream filedb;
	 std::map<std::string, unsigned int> categories;
	 std::multimap<std::string, Product> products;

  private:
	 // Check if category exist in database.
	 bool CategoryExist(const char* category);

  public:
	 TextDB(const char* filename, bool create);
	 ~TextDB(void);
	 
	 // Disconnect database.
	 void Disconnect(void);
	 // Get date of creation.
	 const char* GetCreationDate(void);
	 // Get text version of database.
	 const char* GetDataBase(bool from_file);
	 
	 // Add record to database.
	 void AddProduct(const char* date, const char* category, const char* all_products);
};

#endif /* _TEXT_DB_H_ */
